package com.bank;

import javax.swing.*;

public class CheckingAccount extends Account {
    private double charge;
    public CheckingAccount(String name, int id, String kind, String password, double balance, String record, double charge) {
        super(name, id, kind, password, balance, record);
        this.charge = charge;
    }
    public double getCharge() {
        return charge;
    }
    public void setCharge(double charge) {
        this.charge = charge;
    }
    public void credit(double m){
        double balance1 = getBalance() + m ;
        setBalance( balance1 );
        chargeFee();
    }
    public boolean debit(double n){
        if ( n > getBalance() )
        {
            JOptionPane.showMessageDialog(null, "余额不足", "警告",JOptionPane.WARNING_MESSAGE);
            return false;
        }
        else
        {
            double balance1 = getBalance() - n;
            setBalance( balance1 );
            chargeFee();
            return true;
        } }

    private void chargeFee(){
        double balance1=getBalance()-charge;
        setBalance( balance1 );
    }
}

